package com.gnerv.pabu.plugin.mybatis.plus;

import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class MybatisPlusGroup extends ActionGroup {

    @Override
    public void update(AnActionEvent event) {
        VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
        boolean directory = virtualFile.isDirectory();
        event.getPresentation().setEnabledAndVisible(directory);
    }

    @NotNull
    @Override
    public AnAction[] getChildren(@Nullable AnActionEvent e) {
        return new AnAction[]{
                new CreateControllerClass("创建controller"),
                new CreateServiceClass("创建service"),
                new CreateServiceImplClass("创建serviceImpl"),
                new CreateMapperClass("创建mapper"),
                new CreateMapperXml("创建mapperXml")
        };
    }
}
